Package edu.uky.ai.lp

Class Game

java.lang.Object
edu.uky.ai.lp.Game

public class Game
extends java.lang.Object
Represents the current state of a game of "Hunt the Wumpus."
Author:
Stephen G. Ware
  • Constructor Summary

    Constructors 
    Constructor Description
    Game​(java.lang.String[] map)
    Constructs a new game instance for a given dungeon map.
  • Method Summary

    Modifier and Type Method Description
    boolean breeze​(int file, int rank)
    Tests whether or not a given square has a breeze.
    boolean glitter​(int file, int rank)
    Tests whether or not a given square glitters.
    boolean over()
    Checks whether or not the game has ended.
    boolean pit​(int file, int rank)
    Tests whether or not a given square contains a pit.
    boolean player​(int file, int rank)
    Tests whether or not a given square contains the player.
    boolean stench​(int file, int rank)
    Tests whether or not a given square has a stench.
    boolean visited​(int file, int rank)
    Tests whether or not a given square has been visited.
    boolean wumpus​(int file, int rank)
    Tests whether or not a given square contains the wumpus.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Game

      public Game​(java.lang.String[] map)

      Constructs a new game instance for a given dungeon map. The map should be given as an array of strings, starting with square A4 and ending with square D1.

      The following string values indicate:

      • PL = the player
      • WM = the wumpus
      • PT = a pit
      • GD = the gold

      All other indices should be null.

      Parameters:
      map - the map, as described above
  • Method Details

    • over

      public boolean over()
      Checks whether or not the game has ended.
      Returns:
      true if the game is over, false otherwise
    • visited

      public boolean visited​(int file, int rank)
      Tests whether or not a given square has been visited.
      Parameters:
      file - the file (a=0, b=1, ...) of the given square
      rank - the rank (0=1, 1=2, ...) of the given square
      Returns:
      true if the square has been visited, false otherwise
    • player

      public boolean player​(int file, int rank)
      Tests whether or not a given square contains the player.
      Parameters:
      file - the file (a=0, b=1, ...) of the given square
      rank - the rank (0=1, 1=2, ...) of the given square
      Returns:
      true if the square contains the player, false otherwise
    • wumpus

      public boolean wumpus​(int file, int rank)
      Tests whether or not a given square contains the wumpus.
      Parameters:
      file - the file (a=0, b=1, ...) of the given square
      rank - the rank (0=1, 1=2, ...) of the given square
      Returns:
      true if the square contains the wumpus, false otherwise
    • stench

      public boolean stench​(int file, int rank)
      Tests whether or not a given square has a stench.
      Parameters:
      file - the file (a=0, b=1, ...) of the given square
      rank - the rank (0=1, 1=2, ...) of the given square
      Returns:
      true if the square has a stench, false otherwise
    • pit

      public boolean pit​(int file, int rank)
      Tests whether or not a given square contains a pit.
      Parameters:
      file - the file (a=0, b=1, ...) of the given square
      rank - the rank (0=1, 1=2, ...) of the given square
      Returns:
      true if the square contains a pit, false otherwise
    • breeze

      public boolean breeze​(int file, int rank)
      Tests whether or not a given square has a breeze.
      Parameters:
      file - the file (a=0, b=1, ...) of the given square
      rank - the rank (0=1, 1=2, ...) of the given square
      Returns:
      true if the square has a breeze, false otherwise
    • glitter

      public boolean glitter​(int file, int rank)
      Tests whether or not a given square glitters.
      Parameters:
      file - the file (a=0, b=1, ...) of the given square
      rank - the rank (0=1, 1=2, ...) of the given square
      Returns:
      true if the square glitters, false otherwise